import React, { Component } from 'react';
import {Card,Button,Modal} from 'antd'
import './ui.less'
export default class Modals extends Component {
    state = {

    }
    handleShowModal = (type) => {
        this.setState({
            [type]:true
        })
    }
    handleConfirm = (type) => {
        Modal[type]({
            title:'确认?',
            content: '你确定你学会React了吗？',
            onOK(){
                console.log('ok')
            },
            onCancel(){
                console.log('cancel')
            }
        })
    }
    render() {
        return (
            <div>
                <Card title="基础模态框" className="card-wrapper">
                    <Button type="primary" onClick={ ()=> this.handleShowModal('showModal1')}>Open</Button>
                    <Button type="primary" onClick={ ()=> this.handleShowModal('showModal2')}>自定义页脚</Button>
                    <Button type="primary" onClick={ ()=> this.handleShowModal('showModal3')}>顶部20px弹框</Button>
                    <Button type="primary" onClick={ ()=> this.handleShowModal('showModal4')}>水平垂直居中</Button>
                </Card>
                <Card title="信息确认框" className="card-wrapper">
                    <Button type="primary" onClick={ ()=> this.handleConfirm('confirm')}>Confirm</Button>
                    <Button type="primary" onClick={ ()=> this.handleConfirm('info')}>Info</Button>
                    <Button type="primary" onClick={ ()=> this.handleConfirm('success')}>Success</Button>
                    <Button type="primary" onClick={ ()=> this.handleConfirm('error')}>Error</Button>
                    <Button type="primary" onClick={ ()=> this.handleConfirm('warning')}>Warning</Button>
                </Card>
                <Modal
                    title="React"
                    visible={this.state.showModal1}
                    onCancel={() => {
                        this.setState({
                            showModal1:false
                        })
                    }}
                >
                    欢迎学习慕课新推出的React高级课程
                </Modal>
                <Modal
                    title="React"
                    cancelText = '算了'
                    okText = '好的'
                    visible={this.state.showModal2}
                    onCancel={() => {
                        this.setState({
                            showModal2:false
                        })
                    }}
                >
                    欢迎学习慕课新推出的React高级课程
                </Modal>
                <Modal
                    title="React"
                    style={{top:20}}
                    visible={this.state.showModal3}
                    onCancel={() => {
                        this.setState({
                            showModal3:false
                        })
                    }}
                >
                    欢迎学习慕课新推出的React高级课程
                </Modal>
                <Modal
                    title="React"
                    centered
                    visible={this.state.showModal4}
                    onCancel={() => {
                        this.setState({
                            showModal4:false
                        })
                    }}
                >
                    欢迎学习慕课新推出的React高级课程
                </Modal>
            </div>
        )
    }
}